package com.daily.daily_push.excel;

import com.alibaba.excel.event.WriteHandler;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;

public class CustomTitleStyleHandler implements WriteHandler {

    @Override
    public void sheet(int sheetIndex, Sheet sheet) {
        // 无需实现
    }

    @Override
    public void row(int rowIndex, Row row) {
        // 无需实现
    }

    @Override
    public void cell(int cellIndex, Cell cell) {
        Workbook workbook = cell.getSheet().getWorkbook();
        CellStyle cellStyle = workbook.createCellStyle();

        // 设置标题字体：加粗，14号
        Font font = workbook.createFont();
        font.setBold(true);
        font.setFontHeightInPoints((short) 14);
        cellStyle.setFont(font);

        // 去除背景色（去阴影）
        cellStyle.setFillPattern(FillPatternType.NO_FILL);

        // 应用样式到标题行
        if (cell.getRowIndex() == 0 || cell.getRowIndex() == 1) { // 根据标题层级调整
            cell.setCellStyle(cellStyle);
        }
    }
}